<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>整体审核</title>
    <!-- CSS -->
    <jsp:include page="../include/headtag.jsp" />
    <!-- <link rel="stylesheet"
        href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500"> -->
    <link rel="stylesheet"
          href="assets/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="assets/css/form-elements.css">
    <link rel="stylesheet" href="assets/css/style.css">
    <%
        /********** 保存网站的基本路径 ***********/
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
                + path + "/";
        //将该路径地址缓存到 session中 ,例如：http://localhost:8090/tjnu_ssh_1128/
        session.setAttribute("mybasePath", basePath);
    %>
</head>
<body>
<jsp:include page="../include/head.jsp" />
<jsp:include page="../include/menu.jsp" />
<div id="page-wrapper" style="margin-top: 50px;">
    <div id="page-inner">
        <div class="text-left">
        <a href="/index">首页</a>&nbsp;&gt;&nbsp;<a href="/auditing" class="acts CurrChnlCls">编码审核</a>&nbsp;&gt;&nbsp;<a class="acts CurrChnlCls">待审核列表</a> &nbsp;&gt;&nbsp;<a class="acts CurrChnlCls">整体审核</a>
        </div>
        <div class="row">
            <div class="col-md-12">
                <h3 class="text-left">整体审核</h3>
                <div class="col-md-12">
                    <div class="nav navbar-nav navbar-right">
                        <a href="">整体审核</a>
                    </div>
                </div>
            </div>
        </div>
        <hr />
        <br />
        <div class="container-fluid">
            <form class="form-horizontal table-bordered" role="form">
                <fieldset>
                    <legend>信息部分</legend>
                    <div class="row">
<%--                    <blockquote class="col-sm-9 col-sm-push-1" >--%>
<%--                        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>--%>
<%--                    </blockquote>--%>
                    </div>
                    <br><br>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">方案名称</label>
                            <div class="col-sm-9">
                                <input class="form-control" id="name" type="text" value="${rule.codeRuleName}" readonly/>
                            </div>
                        </div>
                        <br><br>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="cate1">编码类别</label>
                            <div class="col-sm-4">
                                <input class="form-control" id="cate1" type="text" value="${rule.ruleCategoryId}" readonly/>
                            </div>

                            <label class="col-sm-1 control-label" for="cate2">详细类别</label>
                            <div class="col-sm-4">
                                <input class="form-control" id="cate2" type="text" value="${CateName}" readonly/>
                            </div>
                        </div>
                        <br><br>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="intro">方案简介</label>
                            <div class="col-sm-9">
                                <input class="form-control" id="intro" type="text" value="${rule.codeRuleIntro}" readonly/>
                            </div>
                        </div>
                </fieldset>
            </form>

                <br>
                <br>
            <br>
            <br>
            <HR style="border:#987cb9" width="80%" color=#987cb9 SIZE=3>

            <form class="form-horizontal table-bordered" role="form">
                <fieldset>
                    <legend>审核部分</legend>
                    <br><br>
                <c:choose>
                    <c:when test="${record.manageOperation!=1}">
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="unique">唯一性检验</label>
                        <div class="col-sm-9">
                            <input class="form-control result" id="unique" type="text" value="${rongyuflag}" readonly/>
                        </div>
                    </div>
                    <br><br>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="format">基本格式检验</label>
                        <div class="col-sm-9">
                            <input class="result form-control" id="format" type="text" value=1 readonly/>
                        </div>
                    </div>
                    </c:when>
                </c:choose>

                    <br><br>
                    <div class="form-group">
                        <label class="col-sm-2 control-label " for="apply_reason">申请理由审核</label>
                        <div class="col-sm-9">
                            <textarea id="apply_reason" name="reason" class="form-control" style="resize: none;
                                          LINE-HEIGHT:18px;padding: 3px;width:100%;height:100px;max-width:100%;max-height: 100px;" readonly>${record.manageContent}</textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <div >
                            <div class="form-horizontal">
                                <div class="col-lg-2 col-lg-push-3" >
                                    <input type=radio name="pass"  style="zoom:150%;" value=1>
                                    <label >通过</label>
                                </div>

                                <div class="col-lg-2 col-lg-push-6">
                                    <input type=radio name="pass"  style="zoom:150%;" value=0>
                                    <label >不通过</label>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                            <div class="form-horizontal">
                                    <div class="form-horizontal">
                                        <label class="col-sm-2 control-label " for="top_advise">整体审核意见:</label>
                                        <div class="col-lg-9">
                                            <textarea id="top_advise" name="reason" class="form-control" style="resize: none;
                                          LINE-HEIGHT:18px;padding: 3px;width:100%;height:100px;max-width:100%;max-height: 100px;"></textarea>
                                        </div>
                                    </div>
                            </div>
                    </div>

                </fieldset>
            </form>


                <br>
                <br>



<c:choose>
    <c:when test="${record.manageOperation!=1}">
        <div class="row">
            <a id="save" value="save" class="col-lg-3 btn btn-primary btn-sm col-lg-push-3" onclick="convertInfo()">保存</a>
            <a id="next" value="next" class="col-lg-3 btn btn-info btn-sm col-lg-push-4" onclick="redir_to_mid()">下一步</a>
        </div>
    </c:when>


    <c:otherwise>
        <div class="row">
            <a id="confirm" value="save" class="col-lg-4 btn btn-info btn-sm col-lg-push-4" onclick="sub_ab_res()">确定</a>
        </div>
    </c:otherwise>
</c:choose>


                <br>
                <br>


        </div>



    </div>
    <!-- /. PAGE INNER  -->
</div>
<!-- /. PAGE WRAPPER  -->

</body>
<!-- Javascript -->
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/bootstrap/js/jquery.min.js"></script>
<script src="assets/js/jquery.backstretch.min.js"></script>



<script type="text/javascript">

    sub_ab_res = function (){

        var reason_pass =$(":radio[name='pass']:checked").val();

        if($("#top_advise").val()==""){
            alert("请输入整体审核意见！");
            return false;
        }

        if(reason_pass==null){
            alert("请选择该申请是否通过整体审核！");
            return false;
        }

        var url = "/auditing";
        var params = {
            "codeRuleId":${record.newCodeRuleId},
            "recordId":${record.codeRuleManageId},
            "pass":reason_pass,
            "advise":$("#top_advise").val(),
            "op":${record.manageOperation},
        };
        $.ajax({
            url:url,
            data:JSON.stringify(params),
            type:"post",
            success:function (resultData) {
                window.location.href="/auditing";
            },
            error:function (data, status, e){
                alert("审核完成!");
                window.location.href="/auditing";
            },
            dataType:"json",
            contentType: 'application/json',
        });
    }
</script>

<script type="text/javascript">
    $(document).ready(function(){
        flag = 0;
    });
</script>

<script type="text/javascript">
    function redir_to_mid() {


        if (flag==0){
            alert("请先保存整体审核结果！");
        }
        else{
            var record_id = ${record.codeRuleManageId};
            window.location.href = "/auditingMid?id="+record_id;
        }
    }

    function convertInfo(){

        var is_pass = 1
        var reason_pass =$(":radio[name='pass']:checked").val();

        if($("#top_advise").val()==""){
            alert("请输入整体审核意见！");
            flag = 0;
            return false;
        }

        if(reason_pass==null){
            alert("请选择该申请是否通过整体审核！");
            flag = 0;
            return false;
        }


        flag =1
        var u_ = 0;
        var f_ = 0;
        if($("#unique").val()=="通过"){
            u_=1;
        }
        if( $("#format").val()=="通过"){
            f_=1;
        }

        if (u_==1 && f_==1 && reason_pass==1){
            is_pass = 1
        }
        else{
            is_pass = 0
        }

        alert("保存成功！");

        var url = "/auditingTop";
        var params = {"id":0,
            "uniqueCheck":u_,
            "formatCheck":f_,
            "topAdvise":$("#top_advise").val(),
            "isPass":is_pass,
            "ruleId":${rule.codeRuleId},
            "reasonPass":reason_pass,
        };

        $.ajax({
            url:url,
            data:JSON.stringify(params),
            type:"post",
            success:function (resultData) {
                console.log("success");
            },
            dataType:"json",
            contentType: 'application/json',
        });
    }
</script>

<script type="text/javascript">

    $(document).ready(function (){
        $(".result").each(function(){
            // alert($(this).val());
            if($(this).val()=="1"){
                $(this).val("通过");
                $(this).css("background-color","#99FF99");
            }
            else{
                $(this).val("不通过");
                $(this).css("background-color","#FFA488");
            }
        });
    })
</script>

</html>
